#!/usr/bin/python

import sys
import re
import urllib2
import urllib

def listDetailLink(rooturl,filter):
    # read first
    linkpage = urllib2.urlopen(rooturl).read()
    
    # find all the detailed link url
    alllinks = re.findall(r"href=\"(?P<href>.*?)\"", linkpage)
    f = re.compile(filter)
    for link in alllinks:
        if f.match(link):
            print link

def main():
    if(len(sys.argv) != 3):
        print "list all the url defined by regex : <rooturl> <urlpattern>"
        return
    rooturl = sys.argv[1]
    pattern = sys.argv[2]
    listDetailLink(rooturl,pattern)

if __name__ == "__main__":
    main()